package com.party.core.service.crowdfund.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.crowdfund.ProjectInfoGradationReadDao;
import com.party.core.dao.write.crowdfund.ProjectInfoGradationWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.crowdfund.ProjectInfoGradation;
import com.party.core.service.crowdfund.IProjectInfoGradationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @program: party
 * @description: 众筹项目详情_多场-----------------接口实现
 * @author: Hua Qunhao
 * @create: 2019-03-20 19:08
 **/
@Service("ProjectInfoGradationService")
public class ProjectInfoGradationService implements IProjectInfoGradationService {
    @Autowired
    private ProjectInfoGradationWriteDao projectInfoGradationWriteDao;

    @Autowired
    private ProjectInfoGradationReadDao projectInfoGradationReadDao;


    @Override
    public String insert(ProjectInfoGradation projectInfoGradation) {
        BaseModel.preInsert(projectInfoGradation);

        boolean result = projectInfoGradationWriteDao.insert(projectInfoGradation);
        if (result){
            return projectInfoGradation.getId();
        }
        return null;
    }

    @Override
    public boolean update(ProjectInfoGradation projectInfoGradation) {
        projectInfoGradation.setUpdateDate(new Date());
        return projectInfoGradationWriteDao.update(projectInfoGradation);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return projectInfoGradationWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ProjectInfoGradation get(String id) {
        return projectInfoGradationReadDao.get(id);
    }

    @Override
    public List<ProjectInfoGradation> listPage(ProjectInfoGradation projectInfoGradation, Page page) {
        return projectInfoGradationReadDao.listPage(projectInfoGradation,page);
    }

    @Override
    public List<ProjectInfoGradation> list(ProjectInfoGradation projectInfoGradation) {
        return projectInfoGradationReadDao.listPage(projectInfoGradation,null);
    }

    @Override
    public List<ProjectInfoGradation> batchList(Set<String> ids, ProjectInfoGradation projectInfoGradation, Page page) {
        return null;
    }

    @Override
    public Integer getParticipatingNum(String eventGradationId) {
        return projectInfoGradationReadDao.getParticipatingNum(eventGradationId);
    }


    /***
     * 根据projectId找到ProjectInfoGradation
     * @param projectId
     * @return
     */
    @Override
    public ProjectInfoGradation getByProjectGradationId(String projectId) {
        return projectInfoGradationReadDao.getByProjectGradationId(projectId);
    }


    @Override
    public ProjectInfoGradation findByProjectId(String projectId) {
        return projectInfoGradationReadDao.findByProjectId(projectId);
    }

}
